import requests
#登录
ip='http://192.168.68.132/'
loginData = {"username":"wg1","password":"123456","act":"act_login","back_act":"http://192.168.68.132/","submit":""}
r=requests.post(f"{ip}/user.php",data=loginData)
print(r)
#获取cookie
cookie=r.cookies




#新增留言
addLogData={"msg_type":"0","msg_title":"我我我","msg_content":"789456123","act":"act_add_message"}
#文件上传
fname=r'D:\2504\apiTest\datas\2.png'
fData2={'message_img':('2.png',open(fname,'rb'),'image/png')}
r1=requests.post(f"{ip}/user.php",data=addLogData,files=fData2,cookies=cookie)
print(r1)
print(r1.text)